package org.azmat.mybatis.SQL.Mapper;

import org.apache.ibatis.annotations.*;
import org.azmat.mybatis.SQL.Entity.Book;
import org.azmat.mybatis.SQL.uilt.SqlContext;

import java.util.List;

@Mapper
public interface BookMapper {
    // 查询所有书
//    @Select("select * from book")
    public List<Book> selectAllBook();

    // 根据id查询书
//    @Select("select * from book where id = #{id}")
    public Book selectByIdBook(Integer id);

    // 添加一本书
//    @Insert("insert into book (name, price,category, pnum, imgurl, description, author, sales) values (#{name}, #{price},#{category}, #{pnum}, #{imgurl}, #{description}, #{author}, #{sales})")
    public void insertBook(Book book);


    // 修改书
//    @Update("update book set name=#{name},price=#{price},category=#{category},pnum=#{pnum},imgurl=#{imgurl},description=#{description},author=#{author},sales=#{sales} where id=#{id}")
    public void updateBook(Book book);

    // 删除书
//    @Delete("delete from book where id=#{id}")
    public void deleteBook(int id);

//    @SelectProvider(method = "searchBook", type = SqlContext.class)
    public List<Book> searchBooks(Book book);

    public void deleteBooks(int[] id);
}
